﻿Public Class ucButton
    Public Event Clicked(ByVal Sender As Object, ByVal e As EventArgs)
    Public Event Deleted(ByVal Sender As Object, ByVal e As EventArgs)
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        RaiseEvent Clicked(Me, EventArgs.Empty)
    End Sub
    Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter, btnDelete.MouseEnter
        Me.Button1.BackgroundImage = My.Resources.buttonhover
        If _EnableDelete Then
            Me.btnDelete.BackgroundImage = My.Resources.delete
        Else
            Me.btnDelete.Visible = False
        End If

        Me.Button1.ForeColor = Color.Black
    End Sub

    Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave, btnDelete.MouseLeave
        Me.Button1.BackgroundImage = Nothing
        Me.btnDelete.BackgroundImage = Nothing
        Me.Button1.ForeColor = Color.FromArgb(88, 112, 133)
    End Sub
    Public Property Image As Image
        Get
            Return Button1.Image
        End Get
        Set(ByVal Value As Image)
            Button1.Image = Value
        End Set
    End Property
    Public Property ButtonText As String
        Get
            Return Button1.Text
        End Get
        Set(ByVal value As String)
            Button1.Text = value
        End Set
    End Property
    Public Property EnableDelete As Boolean = True

    Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        RaiseEvent Deleted(Me, EventArgs.Empty)
    End Sub
End Class